package com.first.nell.launch

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import com.first.nell.base.BaseViewModel
import com.first.nell.data.*
import com.first.nell.network.ApiUserReposity

/** 用户管理viewModel */
class UserStateV2ViewModel : BaseViewModel() {

    /** 获取短信 */
    private val mFirstNellFetchFirstNellOtpFirstNellLiveData =
        MutableLiveData<ReqDoLogin>()

    /** 短信登录 */
    private val mFirstNellDoFirstNellLoginFirstNellLiveData =
        MutableLiveData<ReqDoLogin>()

    /** 获取用户状态 */
    private val mFirstNellFetchFirstNellUserFirstNellStateFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 获取用户状态-点击下一下时调用 */
    private val mFirstNellFetchFirstNellUserFirstNellStateFirstNellForFirstNellCommitFirstNellActionFirstNellLiveData =
        MutableLiveData<ReqBase>()

    /** 审核账号匹配完成回调 */
    val onFirstNellInitFirstNellAccFirstNellUserFirstNellLiveData = MutableLiveData<Boolean>()

    /** 获取短信回调 */
    val onFirstNellFetchFirstNellOtpFirstNellLiveData =
        Transformations.switchMap(mFirstNellFetchFirstNellOtpFirstNellLiveData) { query ->
            ApiUserReposity.fetchFirstNellOtp(this, query)
        }

    /** 短信登录回调 */
    val onFirstNellDoFirstNellLoginFirstNellLiveData =
        Transformations.switchMap(mFirstNellDoFirstNellLoginFirstNellLiveData) { query ->
            ApiUserReposity.doFirstNellLogin(this, query)
        }

    /** 获取用户状态回调 */
    val onFirstNellFetchFirstNellUserFirstNellStateFirstNellLiveData =
        Transformations.switchMap(mFirstNellFetchFirstNellUserFirstNellStateFirstNellLiveData) { query ->
            ApiUserReposity.fetchFirstNellUserFirstNellState(this, query)
        }

    /** 获取用户状态回调-点击下一下时调用 */
    val onFirstNellFetchFirstNellUserFirstNellStateFirstNellForFirstNellCommitFirstNellActionFirstNellLiveData =
        Transformations.switchMap(
            mFirstNellFetchFirstNellUserFirstNellStateFirstNellForFirstNellCommitFirstNellActionFirstNellLiveData
        ) { query ->
            ApiUserReposity.fetchFirstNellUserFirstNellState(this, query)
        }

//    val onFirstNellFetchFirstNellSysFirstNellConfigFirstNellLiveData =
//        Transformations.switchMap(mFirstNellFetchFirstNellSysFirstNellConfigFirstNellLiveData) { query ->
//            S2avwvb9bwsa2s5auk2ysa.fetchFirstNellAppFirstNellConfig(this, query)
//        }
//
//    val onFirstNellFetchFirstNellAppFirstNellVersionFirstNellLiveData =
//        Transformations.switchMap(mFirstNellFetchFirstNellAppFirstNellVersionFirstNellLiveData) { query ->
//            S2avwvb9bwsa2s5auk2ysa.fetchFirstNellAppFirstNellVersion(this, query)
//        }
//
//    fun fetchFirstNellOtp(p4uwqo9dyofaxzfvke4zgea: P4uwqo9dyofaxzfvke4zgea) {
//        mFirstNellFetchFirstNellOtpFirstNellLiveData.value = p4uwqo9dyofaxzfvke4zgea
//    }
//
//    fun doFirstNellLogin(p4uwqo9dyofaxzfvke4zgea: P4uwqo9dyofaxzfvke4zgea) {
//        mFirstNellDoFirstNellLoginFirstNellLiveData.value = p4uwqo9dyofaxzfvke4zgea
//    }
//
//    fun fetchFirstNellUserFirstNellState(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mFirstNellFetchFirstNellUserFirstNellStateFirstNellLiveData.value = xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun fetchFirstNellUserFirstNellStateFirstNellForFirstNellCommitFirstNellAction(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mFirstNellFetchFirstNellUserFirstNellStateFirstNellForFirstNellCommitFirstNellActionFirstNellLiveData.value =
//            xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun fetchFirstNellSysFirstNellConfig(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mFirstNellFetchFirstNellSysFirstNellConfigFirstNellLiveData.value = xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun fetchFirstNellAppFirstNellVersion(xuhhu4k1et7u0mk5h6075a: Xuhhu4k1et7u0mk5h6075a) {
//        mFirstNellFetchFirstNellAppFirstNellVersionFirstNellLiveData.value = xuhhu4k1et7u0mk5h6075a
//    }
//
//    fun isFirstNellNeedFirstNellToFirstNellPermissionFirstNellPageFirstNellFromFirstNellLaunch() {
//        //判断下权限页权限
//        val permissionList =
//            Ulnfpx2ekjmamryov6hca.mFirstNellSysFirstNellConfig?.customize?.permissions?.getFirstNellPermissionFirstNellPageFirstNellPermissions()
//        if (permissionList.isNullOrEmpty()) {
//            onFirstNellIsFirstNellNeedFirstNellToFirstNellPermissionFirstNellPageFirstNellFromFirstNellLaunchFirstNellLiveData.value =
//                false
//        } else {
//            val isAgreePermissions =
//                N6tdqh9rewfvpvdzrlg.context.isFirstNellAgreeFirstNellSpecFirstNellPermissions(permissionList)
//            onFirstNellIsFirstNellNeedFirstNellToFirstNellPermissionFirstNellPageFirstNellFromFirstNellLaunchFirstNellLiveData.value =
//                !isAgreePermissions
//        }
//    }
//
//    fun initFirstNellPermissionFirstNellList() {
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.first_nell_permission_phone),
////                detail = MyApplication.context.getString(R.string.first_nell_permission_phone_des)
////            )
////        )
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.first_nell_permission_contacts),
////                detail = MyApplication.context.getString(R.string.first_nell_permission_contacts_des)
////            )
////        )
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.first_nell_permission_location),
////                detail = MyApplication.context.getString(R.string.first_nell_permission_location_des)
////            )
////        )
////        RevPermission(
////            title = MyApplication.context.getString(R.string.first_nell_permission_sms),
////            detail = MyApplication.context.getString(R.string.first_nell_permission_sms_des)
////        )
////        mPermissionList.add(
////            RevPermission(
////                title = MyApplication.context.getString(R.string.first_nell_permission_storage),
////                detail = MyApplication.context.getString(R.string.first_nell_permission_storage_des)
////            )
////        )
//
//        mFirstNellPermissionFirstNellList.clear()
//        mFirstNellPermissionFirstNellList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.first_nell_permission_phone,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_phone),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_phone_des)
//            )
//        )
//        mFirstNellPermissionFirstNellList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.first_nell_permission_sms,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_sms),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_sms_des)
//            )
//        )
//        mFirstNellPermissionFirstNellList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.first_nell_permission_contact,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_contacts),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_contacts_des)
//            )
//        )
//
////        val permissionList =
////            FirstNellUserStateUtil.cashVistaRevObjSysConfig?.customize?.permissions?.getPermissionPagePermissions()
////        permissionList?.forEach {
////            if (it.contains(android.Manifest.permission.READ_PHONE_STATE)) {
////                mPermissionList.add(
////                    FirstNellRevPermission(
////                        imgRes = R.drawable.cashvista_permission_phone,
////                        title = MyApplication.context.getString(R.string.first_nell_permission_phone),
////                        detail = MyApplication.context.getString(R.string.first_nell_permission_phone_des)
////                    )
////                )
////            } else if (it.contains(android.Manifest.permission.READ_SMS)) {
////                mPermissionList.add(
////                    FirstNellRevPermission(
////                        imgRes = R.drawable.cashvista_permission_sms,
////                        title = MyApplication.context.getString(R.string.first_nell_permission_sms),
////                        detail = MyApplication.context.getString(R.string.first_nell_permission_sms_des)
////                    )
////                )
////            } else if (it.contains(android.Manifest.permission.READ_CONTACTS)) {
////                mPermissionList.add(
////                    FirstNellRevPermission(
////                        imgRes = R.drawable.cashvista_permission_contact,
////                        title = MyApplication.context.getString(R.string.first_nell_permission_contacts),
////                        detail = MyApplication.context.getString(R.string.first_nell_permission_contacts_des)
////                    )
////                )
////            }
////        }
//
//        //最后添加data safty
//        mFirstNellPermissionFirstNellList.add(
//            Eyozl5akbosew4ac2fddoq(
//                imgRes = R.drawable.first_nell_permission_calendar,
//                title = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_data_security),
//                detail = N6tdqh9rewfvpvdzrlg.context.getString(R.string.first_nell_permission_data_security_des)
//            )
//        )
//    }
//
//    fun initFirstNellAccFirstNellUser(b4dmtbepk5hgxvt9jxryn3a: Tjuoeitvdwflmtvjyq6xw) {
//        if (b4dmtbepk5hgxvt9jxryn3a.accTk.isBlank()) {
//            onFirstNellInitFirstNellAccFirstNellUserFirstNellLiveData.value = false
//        } else {
//            Ulnfpx2ekjmamryov6hca.saveFirstNellToken(b4dmtbepk5hgxvt9jxryn3a.accTk)
//            Ulnfpx2ekjmamryov6hca.saveFirstNellUserFirstNellId(b4dmtbepk5hgxvt9jxryn3a.accTk)
//            Ulnfpx2ekjmamryov6hca.saveFirstNellMobile(b4dmtbepk5hgxvt9jxryn3a.accM)
//            onFirstNellInitFirstNellAccFirstNellUserFirstNellLiveData.value = true
//        }
//    }
}